package exception;

/**
 * @classname:Exception
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/4 17:31
 * @version: 0.1
 * @since:1.8
 */
public class Exception {

    public static int balance = 2000;

    public static void pay(int totalMoney){
        try {
            if (balance<totalMoney) {
                throw new UserBlalanceException(1001,"用户余额不足无法操作");
            }
        }catch (UserBlalanceException e){
            e.printStackTrace();
            System.out.println(e.getCode());
            System.out.println(e.getMsg());
        }
        balance-=totalMoney;
        System.out.println("支付成功，支付了"+totalMoney);
        System.out.println("用户余额剩余"+balance);
    }

    public static void main(String[] args) {
        int money = 100;
        pay(money);
    }
}
